﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

using Newtonsoft.Json.Linq;

using Utils;
using Utils.Weixin;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class WeChatExtensions
    {
        /// <summary>
        /// 开放平台组件
        /// </summary>
        /// <param name="services"></param>
        /// <param name="secretKey"></param>
        /// <returns></returns>
        public static IServiceCollection AddWeChatOpen(this IServiceCollection services, string secretKey)
        {
            return services
                .AddScoped(provider => ActivatorUtilities.CreateInstance<WeChatOpen>(provider, provider.OptionsMonitor<SecretOptions>(secretKey)));
        }

        public static IServiceCollection AddWeChatMini(this IServiceCollection services, string secretKey)
        {
            return services
                .AddScoped(provider => ActivatorUtilities.CreateInstance<WeChatMini>(provider, provider.OptionsMonitor<SecretOptions>(secretKey)));
        }

        public static IServiceCollection AddWeChatOfficial(this IServiceCollection services, string secretKey)
        {
            return services
                .AddScoped(provider => ActivatorUtilities.CreateInstance<WeChatOfficial>(provider, provider.OptionsMonitor<SecretOptions>(secretKey)));
        }

    }
}
